package com.neuedu.controller;

import com.neuedu.common.ResultJson;
import com.neuedu.entity.CheckRequest;
import com.neuedu.service.CheckRequestService;
import com.neuedu.vo.RegisterCheckVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 检查申请表 前端控制器
 * </p>
 *
 * @author LiYang
 * @since 2024-11-17
 */
@RestController
@RequestMapping("/checkRequest")
public class CheckRequestController {
    @Resource
    CheckRequestService checkRequestService;

    /**
     * 开立检查单
     */
    @PostMapping("/add")
    ResultJson<Boolean> add(CheckRequest checkRequest, Long openId) {
        return ResultJson.success(checkRequestService.add(checkRequest, openId), "开立检查单成功");
    }

    /**
     * 查询检查单
     */
    @GetMapping("/list")
    ResultJson<RegisterCheckVo> list(String caseNumber, String checkState){
        return ResultJson.success(checkRequestService.list(caseNumber,checkState));
    }

    /**
     * 查询已缴费的收费项目
     */
    @GetMapping("/jiaofeiList")
    ResultJson<List<CheckRequest>> jiaofeiList(String caseNumber, String realName, String checkState) {
        return ResultJson.success(checkRequestService.jiaofeiList(caseNumber, realName, checkState));
    }


    /**
     * 修改检查单状态  ---已缴费
     */
    @PostMapping("/updateState")
    ResultJson<Boolean> updateState(Integer[] ids){
        return ResultJson.success(checkRequestService.updateState(ids));
    }

    /**
     * 检查项目结果录入
     */
    @PostMapping("/addResult")
    ResultJson<Boolean> addResult(Integer id, String text, Long openId) {
        return ResultJson.success(checkRequestService.addResult(id, text, openId), "结果录入完成");
    }

    /**
     * 查询检查结果
     */
    @GetMapping("/getResult")
    ResultJson<List<CheckRequest>> getResult(Integer registerId, String checkState) {
        return ResultJson.success(checkRequestService.getResult(registerId, checkState));
    }
}
